package com.wowudi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wowudi.entity.Patients;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PatientsMapper extends BaseMapper<Patients> {
    @Select("select * from patients p,register_type rt , register_cost rc ,department_class d ,sys_user su where p.rt_id=rt.rt_id and p.rc_id=rc.rc_id and p.dpc_id=d.dpc_id and p.w_id=su.user_id and pt_isdel=0")
    @ResultMap("BaseResultMap")
    Page<Patients> getAll(@Param("page")Page<Patients> page);
    @Select("select pt_id, pt_card,pt_name,pt_gender ,pt_age,pt_phone,rc_name,dpc_name,user_name,rt_name ,pt_create_time, ts_id from patients p,register_type rt ,  register_cost rc ,department_class d ,sys_user su where p.rt_id=rt.rt_id and p.rc_id=rc.rc_id and p.dpc_id=d.dpc_id and p.w_id=su.user_id and pt_isdel=0 and(p.pt_card =#{cartid} or p.pt_name like CONCAT(CONCAT('%',#{patiname}),'%'))")
    @ResultMap("BaseResultMap")
    Page<Patients> getAllBynameandid(@Param("page")Page<Patients> page,@Param("cartid")String cartid,@Param("patiname")String patiname);
}
